<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>Fluency Questionnaire Survey - Learning a New Language</title>
    <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
    <style>
      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        background-color: #fff;
        color: #333;
      }

      .dark body {
        background-color: #1a1a1a;
        color: #f5f5f5;
      }

      /* 进度条样式 */
      .progress-container {
        height: 4px;
        width: 100%;
        background-color: #f0f0f0;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
      }

      .progress-bar {
        height: 100%;
        background-color: #007aff;
        width: 35%; /* 进度：8步中的第3步 */
      }

      .dark .progress-container {
        background-color: #333;
      }

      /* 顶部导航 */
      .top-nav {
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .back-btn {
        color: #007aff;
        font-size: 1.25rem;
        cursor: pointer;
      }

      /* 内容区域 */
      .content {
        max-width: 500px;
        margin: 0 auto;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
      }

      /* 选项卡片 */
      .option-card {
        width: 400px;
        padding: 1rem;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        margin-bottom: 1rem;
        cursor: pointer;
        transition: all 0.2s;
      }

      .option-card:hover,
      .option-card.selected {
        border-color: #007aff;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
      }

      .option-card.selected {
        background-color: rgba(0, 122, 255, 0.1);
      }

      .option-title {
        font-weight: 600;
      }

      .option-check {
        display: flex;
        align-items: center;
        justify-content: center;
      }

      /* 按钮样式 */
      .btn-primary {
        background-color: #007aff;
        color: white;
        padding: 0.75rem 1.5rem;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
        width: 100%;
        justify-content: center;
        border: none;
      }

      .btn-primary:hover {
        background-color: #0062cc;
      }

      .btn-primary:disabled {
        background-color: #c7c7cc;
        cursor: not-allowed;
      }

      /* 适配黑暗模式 */
      .dark .option-card {
        border-color: #4a5568;
        background-color: #2d3748;
      }

      .dark .option-card:hover,
      .dark .option-card.selected {
        border-color: #0a84ff;
      }

      .dark .option-card.selected {
        background-color: rgba(10, 132, 255, 0.2);
      }

      /* 主题切换按钮 */
      .theme-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-color: #007aff;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        z-index: 1000;
      }

      .theme-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
      }

      .nav-progress-container {
        display: flex;
        align-items: center;
        margin-bottom: 40px;
        gap: 15px;
      }

      .back-button {
        width: 30px;
        height: 30px;
        border: none;
        background: none;
        cursor: pointer;
        color: #2b85e4;
        font-size: 20px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .back-button svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
      }

      .progress-bar {
        flex: 1;
        height: 6px;
        width: 423px;
        background-color: #e0e0e0;
        border-radius: 3px;
      }

      .progress {
        height: 100%;
        width: 29.97%;
        background-color: #2b85e4;
        border-radius: 3px;
      }
    </style>
    <script>
      // 检查深色模式
      function checkDarkMode() {
        if (
          localStorage.getItem('darkMode') === 'true' ||
          (localStorage.getItem('darkMode') === null && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ) {
          document.documentElement.classList.add('dark')
          return true
        }
        return false
      }

      // 切换深色/浅色模式
      function toggleDarkMode() {
        if (document.documentElement.classList.contains('dark')) {
          document.documentElement.classList.remove('dark')
          localStorage.setItem('darkMode', 'false')
          document.getElementById('theme-icon').className = 'fas fa-moon'
        } else {
          document.documentElement.classList.add('dark')
          localStorage.setItem('darkMode', 'true')
          document.getElementById('theme-icon').className = 'fas fa-sun'
        }
      }

      function selectOption(element) {
        // 移除所有其他选项的选中状态
        document.querySelectorAll('.option-card').forEach(card => {
          card.classList.remove('selected')
          card.querySelector('.option-check').classList.remove('bg-blue-500')
          card.querySelector('.option-check').innerHTML = ''
        })

        // 添加当前选项的选中状态
        element.classList.add('selected')
        const checkIcon = element.querySelector('.option-check')
        checkIcon.classList.add('bg-blue-500')
        checkIcon.innerHTML = '<i class="fas fa-check text-white text-xs"></i>'

        // 获取页面标题和当前页面名称
        const pageTitle = document.querySelector('.text-3xl').textContent.trim()
        const pageName = window.location.pathname.split('/').pop().split('.')[0]
        const selectedValue = element.dataset.value
        const selectedTitle = element.querySelector('.option-title').textContent.trim()

        // 创建数据对象
        const data = {
          title: pageTitle,
          value: selectedTitle,
          lastLearning: selectedValue,
        }

        // 以JSON格式存储到localStorage
        localStorage.setItem(pageName, JSON.stringify(data))

        // 保留原有存储方式，以保证兼容性
        localStorage.setItem('lastTimeLearning', selectedValue)

        // 跳转到下一页
        window.location.href = '/howDid.html'
      }

      // 当DOM加载完成
      document.addEventListener('DOMContentLoaded', function () {
        const isDark = checkDarkMode()
        document.getElementById('theme-icon').className = isDark ? 'fas fa-sun' : 'fas fa-moon'
      })
    </script>
  </head>
  <body>
    <!-- 主内容区 -->
    <div class="content">
      <div class="nav-progress-container">
        <button class="back-button" onclick="window.location.href='/setYour.html'">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" />
          </svg>
        </button>
        <div class="progress-bar">
          <div class="progress"></div>
        </div>
      </div>
      <!-- 页面标题 -->
      <h1 class="text-3xl font-bold mb-2 text-[#0B4983] text-center">
        When was the last time you learned a new language?
      </h1>
      <p class="text-gray-600 dark:text-gray-400 mb-8"></p>

      <!-- 选项 -->
      <div class="space-y-4 mb-8">
        <div class="option-card" onclick="selectOption(this)" data-value="recently">
          <div class="flex items-center justify-between">
            <div class="option-title">Recently</div>
            <div class="w-6 h-6 rounded-full border-2 border-gray-300 option-check"></div>
          </div>
        </div>

        <div class="option-card" onclick="selectOption(this)" data-value="a_year_ago">
          <div class="flex items-center justify-between">
            <div class="option-title">A year ago</div>
            <div class="w-6 h-6 rounded-full border-2 border-gray-300 option-check"></div>
          </div>
        </div>

        <div class="option-card" onclick="selectOption(this)" data-value="more_than_a_year_ago">
          <div class="flex items-center justify-between">
            <div class="option-title">More than a year ago</div>
            <div class="w-6 h-6 rounded-full border-2 border-gray-300 option-check"></div>
          </div>
        </div>

        <div class="option-card" onclick="selectOption(this)" data-value="never">
          <div class="flex items-center justify-between">
            <div class="option-title">Never</div>
            <div class="w-6 h-6 rounded-full border-2 border-gray-300 option-check"></div>
          </div>
        </div>
      </div>

      <!-- 下一步按钮，这里可以注释掉或删除 -->
      <button id="next-button" disabled class="btn-primary" onclick="window.location.href='/howDid.html'">
        下一步 <i class="fas fa-arrow-right ml-2"></i>
      </button>
    </div>

    <!-- 主题切换按钮 -->
    <div class="theme-toggle" onclick="toggleDarkMode()">
      <i id="theme-icon" class="fas fa-moon"></i>
    </div>
  </body>
</html>
